<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <title>资产</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="/statics/layui/css/layui.css" media="all">
</head>

<body>

  <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
    <legend>代币资产</legend>
  </fieldset>
  <table class="layui-hide" id="dg1" lay-filter="dg1"></table>

  <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
    <legend>DG资产</legend>
  </fieldset>
  <table class="layui-hide" id="dg2" lay-filter="dg2"></table>

  <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
    <legend>投资币种</legend>
  </fieldset>
  <table class="layui-hide" id="dg3" lay-filter="dg3"></table>

  <script src="/statics/layui/layui.js" charset="utf-8"></script>
  <script type="text/javascript" src="../js/jquery-1.11.0.min.js"></script>
  <script type="text/javascript" src="../js/config.js"></script>
  <script type="text/javascript" src="../js/utils.js"></script>
  <script>
    var MyMoney = {
      "init": function () {
        DataUtils.getUserMoneyList(function (data) {
          var data1=[],data2=[],data3=[];
          if(data && data.length > 0){
            for(var i=0;i<data.length;i++){
              var item = data[i];
              if(item.moneyType){
                switch(item.moneyType.typeMode){
                  case 0:
                    data1.push(item);
                  break;
                  case 1:
                    data3.push(item);
                  break;
                  case 2:
                    data2.push(item);
                  break;
                }
              }
            }
          }
          layui.use(['table'], function () {
            var table = layui.table;

            table.render({
              elem: '#dg1',
              cellMinWidth: 80, //全局定义常规单元格的最小宽度，layui 2.2.1 新增
              cols: [[
                { field: 'typeName', title: '币种' },
                { field: 'money', title: '剩余数量', templet: MyMoney.formatMoney }
              ]],
              even: true,
              data:data1
            });

            table.render({
              elem: '#dg2',
              cellMinWidth: 80, //全局定义常规单元格的最小宽度，layui 2.2.1 新增
              cols: [[
                { field: 'typeName', title: '币种' },
                { field: 'money', title: '剩余数量', templet: MyMoney.formatMoney }
              ]],
              even: true,
              data:data2
            });

            table.render({
              elem: '#dg3',
              cellMinWidth: 80, //全局定义常规单元格的最小宽度，layui 2.2.1 新增
              cols: [[
                { field: 'typeName', title: '币种' },
                { field: 'money', title: '剩余数量', templet: MyMoney.formatMoney }
              ]],
              even: true,
              data:data3
            });

          });
        });
      },
      "formatMoney":function(d){
        if(d.money>0){
          return '<span style="color:red;">'+d.money+'</span>';
        }else{
          return '<span style="color:green;">'+d.money+'</span>';
        }
      }
    };
    $(function () {
      MyMoney.init();
    });
  </script>

</body>

</html>